package com.lbssoft.gpsbd.controller;

import com.lbssoft.gpsbd.model.Result;
import com.lbssoft.gpsbd.model.vo.RoleVo;
import com.lbssoft.gpsbd.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api("数据字典")
@RestController
@RequestMapping("/common")
public class CommonController {

	@Autowired
	private RoleService roleService;

	@ApiOperation(value="获取角色数据", notes="获取角色数据")
	@RequestMapping(value = "roles",method = {RequestMethod.GET})
	@ResponseBody
	public Result roles() {
		Result result = new Result();
		List<RoleVo> list = roleService.list();
		Map map = new HashMap();
		for(RoleVo role:list){
			map.put(role.getRoleKey(),role.getName());
		}
		result.setData(map);
		return result;
	}
	
}